\section{Result and Evaluation}
\label{subsec:evaluate}

In evaluating our approach, we have created two test cases for checking if our
approach did successfully discover deadlock and infinite loop. We state the
evaluation approach and the result of the evaluation of the deadlock and
infinite loop in Section~\ref{subsec:deadlock_result} and Section~\ref{subsec:infiniteloop_result}.

\subsection{Deadlock's Evaluation Result}
\label{subsec:deadlock_result}
We created a test program that consists of two threads \textit{t1} and
\textit{t2} holding resources \textit{R1} and \textit{R2} respectively from the
start. After some time, both threads try to get the other resource but each of
them is already holding the requested resources. In this case, a deadlock has
occurred.

We displayed a fragment portion of our test case source in
figure~\ref{fig:deadlock_source} and the evaluation result is shown in
figure~\ref{fig:deadlock_result}. In figure~\ref{fig:deadlock_source}, we
created two thread classes that are trying to get each other's resource at a
certain time and spawn a thread instance from each of them. From the result, we
can see that our implemented algorithm is able to detect the deadlock and print
the deadlock information (which includes the source line number) to the user
successfully. The displaying of the source line number will enable the
programmer to diagnose the cause of the deadlock, and implemented alternative
algorithm to prevent this deadlock from occurring. 

\begin{figure}
    \centering
    \includegraphics{images/deadlock_source.png}
    \caption{The program is able to enter a deadlock state after some time
    when the two threads are starting simultaneously.}
    \label{fig:deadlock_source}
\end{figure}


\begin{figure}
    \centering
    \includegraphics{images/deadlock_result.jpg}
    \caption{The program is able to detect and display the deadlock information
    to the user.}
    \label{fig:deadlock_result}
\end{figure}


\subsection{Infinite Loop's Evaluation Result}
\label{subsec:infiniteloop_result}
we created a test program that consists of method calls being executed
repeatedly inside the while loop. In figure~\ref{fig:loop_source}, we showed a
while loop block where method calls are being executed inside but there is no
single point of exit out of this loop block. This creates an infinite loop where
methods are being executed repeated.

As we can see from the result in figure~\ref{fig:loop_result}, our technique is
able to detect infinite loop accurately by detecting the common repeated
pattern found in the method execution. If the pattern count reaches 1000, we
will suspect that this is an infinite loop and prompt the user whether he would
like to exit the loop. The prompting is necessary as there is a possibility that
the user has manually set the methods to run for 1000 time for whatever special
reasons. We do not want to cause the program to terminate prematurely by
forcefully termininating it on its own. 
\begin{figure}
    \centering
    \includegraphics{images/loop_source.png}
    \caption{The program enters a while loop and there is no exit point to
    leave this block, therefore it enters an infinite loop state.}
    \label{fig:loop_source}
\end{figure}


\begin{figure}
    \centering
    \includegraphics{images/loop_result.png}
    \caption{The program is able to detect and infinite loop and prompt the
    user if he wants to break out of the infinite loop.}
    \label{fig:loop_result}
\end{figure}
